<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>后台管理主页</title>
		<link rel="stylesheet" type="text/css" href="/css/manager.css" />
		<script src="/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/manager_siderlist.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				$("#categorylist").change(function() {
					var selected_text = $(this).find("option:selected").text();
					var selected_val = $(this).find("option:selected").val();
					//判断不能选择默认项
					if(selected_val == 0) {
						$("#catename").val("");
					} else {
						var mytext = getStr(selected_text, "|");
						$("input#cateid").val(selected_val);
						$("input#catename").val(mytext);
					}
				});
				
				$("#categorylist_upid").change(function(){
					var selected_val = $(this).find("option:selected").val();
					$("input#cate_pid").val(selected_val);
				});
				
				//提交验证
				$("#modify_form").submit(function(){
					var cate_id=$("input#cateid").val();
					var cate_name=$("input#catename").val();
					if(cate_id==null||cate_id==0||cate_name==null||cate_name==""){
						alert("请正确选择修改分类和填写修改内容");
						return false;
					}
				});
			});

			//过滤函数
			function getStr(mystr, char) {
				if(mystr.indexOf(char)>-1) {
					//var str_before = string.split(char)[0];					
					var str_after = mystr.split(char)[1];
					return str_after.trim();
				}else{
					return mystr.trim();
				}
			}
		</script>
	</head>

	<body>
		<div id="container">
			<!--顶部-->
			<% include ../template/manager_header.html %>
			<!--内容-->
			<div id="content">
				<div class="top_nav">
					<a href="#">管理首页</a>>>
					<a href="#">XX管理</a>>>
					<a href="#">XX页面</a>
				</div>
				<div class="content_panel clearfix">
					<!--侧边管理链接-->
					<% include ../template/manager_siderlist.html %>
					<div class="panel_right fr">
						<!--分类管理-->
						<div class="category_list">
							<form id="modify_form" action="/manager/modify_category" method="post">
							<table id="list_style" class="catelist">
								<thead>
									<tr>
										<th colspan="2">分类管理</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td class="left">请选择被修改的分类内容：</td>
										<td>
											<select id="categorylist" name="category">
												<%for(var i=0;i<categorylist.length;i++){%>
												<option value="<%=categorylist[i].category_Id%>">
													<%=categorylist[i].category_name.trim()%>
												</option>
												<%}%>
											</select>
										</td>
									</tr>
									<tr>
										<td class="left">请选择被修改的分类要移动的节点：</td>
										<td>
											<select id="categorylist_upid" name="category">
												<%for(var i=0;i<categorylist.length;i++){%>
												<option value="<%=categorylist[i].category_Id%>">
													<%=categorylist[i].category_name.trim()%>
												</option>
												<%}%>
											</select>
											<span class="red">
												不选择默认是跟节点
											</span>
										</td>
									</tr>
									<tr>
										<td class="left">修改分类内容：</td>
										<td>
											<input type="text" style="display: none;" id="cateid" name="cateid" />
											<input type="text" style="display: none;" id="cate_pid" name="cate_pid" />
											<input type="text" id="catename" name="catename" value="" /> </td>
									</tr>
									<tr>
										<td colspan="2" class="submit_btn"><input type="submit" id="submit_btn" value="提交" name="" /></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td colspan="2" class="h30">
										</td>
									</tr>
								</tfoot>
							</table>
						    </form>
						</div>
					</div>
				</div>
			</div>
			<!--底部-->
			<% include ../template/manager_footer.html %>
		</div>

	</body>

</html>